package com.tkafka.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/5/24  16:26
 * 描述:
 */
@RestController
public class KafkaController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;


    @RequestMapping("/send/{msg}")
    public Object sendMsg(@PathVariable("msg") String msg){

        String string = UUID.randomUUID().toString();

        kafkaTemplate.send("HHHH",string,msg);

        return "ok";
    }

}
